package logic

import (
	"context"
	"day15/model/mysql"

	"day15/rpc/internal/svc"
	"day15/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpdatePwdLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUpdatePwdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpdatePwdLogic {
	return &UserUpdatePwdLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserUpdatePwdLogic) UserUpdatePwd(in *pb.UserUpdatePwdReq) (*pb.UserUpdatePwsResp, error) {
	userModel := mysql.User{}
	err := userModel.UpdatePwd(in.Phone, in.Password)
	if err != nil {
		return nil, err
	}
	return &pb.UserUpdatePwsResp{}, nil
}
